#ifndef __DAISY_BASE_TOOLS_DYNAMIC_LIB_IMPL_H__
#define __DAISY_BASE_TOOLS_DYNAMIC_LIB_IMPL_H__

#include "BaseToolsConfig.h"
#include "DynamicLib.h"

//#if ORZ_PLATFORM == ORZ_PLATFORM_WIN32
#    define DYNLIB_HANDLE hInstance
#    define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )

struct HINSTANCE__;
typedef struct HINSTANCE__* hInstance;

//#elif ORZ_PLATFORM == ORZ_PLATFORM_LINUX
//#    define DYNLIB_HANDLE void*
//#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
//#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
//#    define DYNLIB_UNLOAD( a ) dlclose( a )
//#endif

namespace DAISY {

   
	class _DaisyBaseToolsPrivate DynamicLibImpl
    {

    public:
      
		DynamicLibImpl( const std::string & name );
		DynamicLibImpl(const DynamicLibImpl & dl);
		DynamicLibImpl& operator = (const DynamicLibImpl& dl);

        ~DynamicLibImpl();

        void load();
        
        void unload();
		
		inline const std::string & getName(void) const { return _name; }

    
        void* getSymbol( const std::string& strName ) const throw();

	private:

		 std::string dynlibError(void);


		std::string _name;
        /// Handle to the loaded library.
        DYNLIB_HANDLE _hInst;
    };

}

#endif
